Conversation
|
This looks awesome and I'm super excited for getting the whole nock interface. What happens if a call to nock is made with the wrong arguments, or to an undefined method? Does comlink report back the errors in the browser? |
| }, | ||
| "scripts": { | ||
| "build": "ember build", | ||
| "install": "cd node_modules/comlink && npm install && npm run build", |
There was a problem hiding this comment.
Does comlink need to be compiled? Does this have any negatives or gotchas?
There was a problem hiding this comment.
Yeah, the compile step is necessary when using the git repo source. Comlink’s written in TypeScript, and gets compiled to JS when published to npm, so here we need to do it on our own.
It’s just a temporary solution for sharing this work-in-progress. I wouldn’t even try publishing ECFT with it. 😅
| }, | ||
| "dependencies": { | ||
| "body-parser": "^1.18.3", | ||
| "comlink": "CvX/comlink#wrap-chain", |
There was a problem hiding this comment.
I know you added some stuff here to get the chaning working. Should we wait for them to merge it or depend on this branch?
There was a problem hiding this comment.
Continuing from the previous comment: I wouldn’t use this setup. I’d either wait for a comlink release or, in case that gets stuck, I’d push a fork of comlink with chain method calls to npm.
| }); | ||
|
|
||
| test('it can mock an array of models', async function(assert) { | ||
| await nock('http://localhost:7357') |
There was a problem hiding this comment.
Is it possible to auto detect the local hostname and not require it here?
There was a problem hiding this comment.
We could set the hostname in the application adapter, and use that here. It wouldn’t then change when, for example, using a different testing port.
The error message quality may vary 😉 but yeah, the errors get proxied back to the browser. For example: await nock('http://localhost:7357').intercept().reply(200, { ok: true }); |
Implements the
nockproxy originally mentioned in #53:The code quality is very much at the "proof of concept" level, but it does work.
You can see usage examples in tests: https://github.com/CvX/ember-cli-fastboot-testing/blob/5bc6c47fec9669eff338f6d1098c58ea1b6c9213/tests/fastboot/nock-proxy-test.js
The
postMessage()/addEventListener()architecture of comlink doesn't mesh well with the HTTP client/server stuff we have in ECFT. It might be a good idea to replace that with Web Sockets, though that might have issues of its own. We'll see!Closes #53
Closes #50